﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleAppDoublePrescion
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var random = new Random();
            var list = new List<DoublePoint>();
            for (var i = 0; i < 100; i++)
            {
                var y = Math.Round(random.NextDouble() * 100, 6);
                list.Add(new DoublePoint { X = i, Y = Math.PI*y*y });
            }

            var max = list.Average(l => l.Y);
            var ss = list.FirstOrDefault(l =>max.AlmostEquals(l.Y));
            Console.ReadLine();
        }
    }

    internal struct DoublePoint
    {
        public double X { get; set; }
        public double Y { get; set; }
    }

    static class NumberExtension
    {
        public static bool AlmostEquals(this double double1, double double2, double precision = 0.000001)
        {
            return (double.IsNaN(double1) && double.IsNaN(double2)) || (Math.Abs(double1 - double2) <= Math.Abs(precision));
        }
    }
}